-- ArenaFlag
-- Created by chengb Dec/16/2015
-- 角斗台白旗格子

-- 初始化
function initArenaFlag(self)
    self.item:removeAllChildren();

    local function onClicked(sender, eventType)
        if eventType == ccui.TouchEventType.began then
            -- 逃离
            local function flee()
                -- TODO 播放音效，观众嘘声

                alert(getLocStr("arena_flee_tip"));
                AudioM.playFx("arena_surrender");
                DungeonActionM.go("flee_arena");
            end

            self:openBuildingView(flee);
            AudioM.playFx("button_spell");
        end
    end

    local iconPath = getLevelItemIconPath("arena_flag");
    self.icon = ccui.ImageView:create(iconPath);
    self.icon:setTouchEnabled(true);
    self.icon:addTouchEventListener(onClicked);
    self.item:addChild(self.icon);
end
